package com.kingyea.mobilepolice.orgrole.service.impl;

import com.kingyea.mobilepolice.orgrole.bean.OrgRole;
import com.kingyea.mobilepolice.orgrole.bean.OrgRoleCondition;
import com.kingyea.mobilepolice.orgrole.dao.OrgRoleMapper;
import com.kingyea.mobilepolice.orgrole.service.OrgRoleService;
import com.kingyea.mobilepolice.system.StateCode;
import com.kingyea.mobilepolice.util.ExceptionConditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Mr.Lin
 * @version v1.0.0
 * @description OrgRole 实现类
 * @date Created in 2018-04-26 15:25:13
 */
@Service
@Transactional
public class OrgRoleServiceImpl implements OrgRoleService {

    private static final Logger LOGGER = LoggerFactory.getLogger(OrgRoleServiceImpl.class);

    @Resource
    private OrgRoleMapper orgRoleMapper;

    /**
     * 列表
     *
     * @param condition
     * @return
     */
    @Override
    public List<OrgRole> search(OrgRoleCondition condition) {
        List<OrgRole> list = orgRoleMapper.search(condition);
        return list;
    }

    /**
     * 删除
     *
     * @param orgSerialNo
     * @return
     */
    @Override
    public Boolean deleteByOrgSerialNo(String orgSerialNo) {
        return orgRoleMapper.deleteByOrgSerialNo(orgSerialNo) > 0;
    }

    /**
     * 保存
     *
     * @param orgRole
     * @return
     */
    @Override
    public Boolean save(OrgRole orgRole) {
        return orgRoleMapper.save(orgRole) > 0;
    }

    @Override
    public Boolean batchSave(List<OrgRole> orgRoles) {
        ExceptionConditions.checkArrayNotEmpty(orgRoles, StateCode.NO_ARGUMENT_ERROR);
        return orgRoleMapper.batchSave(orgRoles) == orgRoles.size();
    }
}
